1
00:00:01,120 --> 00:00:08,100
‫When it comes to the eve lecture and in this lecture, we are now going to be starting adding items

2
00:00:08,100 --> 00:00:11,860
‫to our to our database, using our API.

3
00:00:12,180 --> 00:00:17,910
‫So if you have not watched the previous lectures, I would recommend you to strongly go back and watch

4
00:00:17,910 --> 00:00:19,930
‫them so that you are able to catch up with us.

5
00:00:19,950 --> 00:00:27,120
‫So let me come down here and I'm going to do here quickly is I am going to define my function that is

6
00:00:27,120 --> 00:00:31,200
‫going to use to add an item to our database.

7
00:00:31,680 --> 00:00:37,260
‫And then what I'm going to do here is I am going to start writing code that is going to be adding items

8
00:00:37,260 --> 00:00:38,250
‫to our table.

9
00:00:38,280 --> 00:00:40,530
‫Here we have two items as us, as Assad.

10
00:00:40,560 --> 00:00:44,040
‫Now, you can see from our database level we have two items.

11
00:00:44,220 --> 00:00:45,960
‫We, of course, and we have this other thing.

12
00:00:46,380 --> 00:00:52,980
‫And from our our ERP next instance, the items DOCTYPE has two items.

13
00:00:53,010 --> 00:00:55,310
‫OK, these are just for the purpose of this video.

14
00:00:55,320 --> 00:00:57,180
‫So let's jump into the code quickly.

15
00:00:57,600 --> 00:01:06,390
‫And I'm going to be defining a variable here called add item and I'm going to be equating that to Frappé

16
00:01:06,990 --> 00:01:07,460
‫Dot.

17
00:01:07,470 --> 00:01:11,850
‫So make sure you you type with me so that you understand what this thing is doing.

18
00:01:12,060 --> 00:01:15,780
‫So I'm going to get the document that I want to edit.

19
00:01:16,210 --> 00:01:18,320
‫OK, so this is very important.

20
00:01:18,330 --> 00:01:25,890
‫So document not document but doctype sorry doctype so what you are going to do here when you need to

21
00:01:25,920 --> 00:01:33,150
‫add items instead of Europea next, just get the document that you want to edit and then with from within

22
00:01:33,150 --> 00:01:33,870
‫the document.

23
00:01:34,770 --> 00:01:38,760
‫Of course the document is item and document is code item from within here.

24
00:01:38,790 --> 00:01:41,000
‫Now we can go ahead and tell it what you want to do here.

25
00:01:41,310 --> 00:01:47,430
‫What you want to do is want to do it, add some stuff and I am going to hardcourt this stuff for this

26
00:01:48,120 --> 00:01:48,660
‫for now.

27
00:01:48,900 --> 00:01:53,190
‫And then later in this course, we are going to pass them from our from another application.

28
00:01:53,200 --> 00:01:57,890
‫So we are going to be expecting these things to come so that, for instance, if you are having and

29
00:01:57,900 --> 00:02:04,350
‫mobile up, these items are going to be added inside ERP next from a mobile app.

30
00:02:04,890 --> 00:02:07,040
‫But for this one, I'm going to be recording them here.

31
00:02:07,230 --> 00:02:11,070
‫We are going to see how you're going to expect them there in the next the next year.

32
00:02:11,090 --> 00:02:12,150
‫That is in literature name.

33
00:02:12,330 --> 00:02:16,740
‫So in this one, I want to show you how to had them and send them into a database.

34
00:02:16,740 --> 00:02:23,340
‫So when we come to our instance here, we see that when we click on ADD Item, we have things here that

35
00:02:23,340 --> 00:02:23,930
‫are mandatory.

36
00:02:23,940 --> 00:02:31,760
‫So you cannot save an item inside of this table unless you you add an item code, an item group and

37
00:02:31,870 --> 00:02:32,750
‫the unit of measure.

38
00:02:33,060 --> 00:02:38,610
‫And I'm going to do is I am also going to add an item names a lot of positive looks, looks fancy.

39
00:02:38,640 --> 00:02:38,960
‫All right.

40
00:02:39,450 --> 00:02:46,020
‫So going back to the database level so that we can get the item code, the names that we need in the

41
00:02:46,020 --> 00:02:50,310
‫table in our database is I know this one is item code.

42
00:02:50,760 --> 00:02:56,370
‫So if you are working on a different type of doctor, but you are supposed to do go to the to the database

43
00:02:56,370 --> 00:03:04,500
‫level and see what those things are called, if you do not know how to do that live or if you have not

44
00:03:04,500 --> 00:03:12,870
‫installed, for instance, your ERP next instance, what you need to do is to check from a user from

45
00:03:12,870 --> 00:03:14,360
‫you are from your Tamino here.

46
00:03:14,370 --> 00:03:19,590
‫So let me clear this and get out.

47
00:03:19,590 --> 00:03:20,680
‫Get out completely.

48
00:03:21,060 --> 00:03:28,320
‫I just want to show you how you can you can you can check columns in the table, OCD to Hoppity and

49
00:03:28,320 --> 00:03:30,720
‫then to bench and then from bench.

50
00:03:30,720 --> 00:03:35,430
‫What we need to do is go to Carani is the instance we are working with.

51
00:03:35,730 --> 00:03:46,800
‫And then he began to change my mind about Maria, Maria, Déby, and he said of Maria Debe, and I can

52
00:03:46,800 --> 00:03:54,750
‫do something like describe the table, name is the table.

53
00:03:54,750 --> 00:03:57,050
‫Name is Tab item.

54
00:03:57,090 --> 00:03:57,990
‫I think so.

55
00:04:10,520 --> 00:04:18,760
‫President, yeah, so here we have you have our table, so we have a name, we have agreed that we have

56
00:04:18,760 --> 00:04:20,710
‫all these things we can see item group here.

57
00:04:21,070 --> 00:04:23,010
‫You can see item, name, item group.

58
00:04:23,200 --> 00:04:24,860
‫So what we need to get here.

59
00:04:24,880 --> 00:04:25,420
‫So let's see.

60
00:04:25,420 --> 00:04:26,250
‫Let's go back here.

61
00:04:26,530 --> 00:04:28,360
‫We need the item code.

62
00:04:29,080 --> 00:04:30,700
‫So let's go back here.

63
00:04:30,700 --> 00:04:32,050
‫What is the item code?

64
00:04:32,680 --> 00:04:33,490
‫Let's see.

65
00:04:33,610 --> 00:04:36,100
‫Item code is here so you can copy that.

66
00:04:36,790 --> 00:04:37,960
‫Come with it to your code.

67
00:04:38,440 --> 00:04:39,250
‫Put it here.

68
00:04:39,250 --> 00:04:40,350
‫That is what we had there.

69
00:04:40,630 --> 00:04:44,950
‫So in this one, again, can just do something like X, X, X, X, OK?

70
00:04:46,660 --> 00:04:53,350
‫And then we, we have, um, we need a comma here.

71
00:04:55,060 --> 00:04:58,360
‫We will have another thing that we need to to change.

72
00:04:58,740 --> 00:05:01,150
‫Remember, this is Python, so we need to do proper indentation.

73
00:05:01,690 --> 00:05:08,650
‫The other thing we need to add here is the item name so you can go back and see the item name is this

74
00:05:08,650 --> 00:05:08,920
‫one.

75
00:05:08,920 --> 00:05:11,650
‫So copy that, go back with it here.

76
00:05:12,160 --> 00:05:20,620
‫And I can call this something like fast API item and then comma.

77
00:05:20,920 --> 00:05:25,030
‫And then the next thing that we need from here is the item group.

78
00:05:25,030 --> 00:05:27,910
‫So come back here with the item group is here.

79
00:05:27,910 --> 00:05:31,780
‫Copy that then pasted here and the item group.

80
00:05:31,780 --> 00:05:35,830
‫Remember we have groups already that are set in the in the database.

81
00:05:35,830 --> 00:05:45,340
‫So I'm going to say this is services and then I'm going to have another one which is the default unit

82
00:05:45,340 --> 00:05:46,090
‫of measure.

83
00:05:46,840 --> 00:05:50,620
‫And what is the unit of measure called in this table.

84
00:05:54,260 --> 00:05:55,890
‫Oh, I have broken this.

85
00:05:56,780 --> 00:05:58,790
‫Let me just quit.

86
00:06:01,780 --> 00:06:14,550
‫Rescue is the wanted Skip, so let me just close it and open it again, or you open it again, then

87
00:06:14,550 --> 00:06:18,440
‫I do bench Maria, Maria, Debe.

88
00:06:20,640 --> 00:06:24,180
‫So this one is karani, so I need to do so door to door.

89
00:06:24,180 --> 00:06:29,910
‫So you are up next and then my password is not one.

90
00:06:30,370 --> 00:06:37,740
‫Then I do pity Bench and Karani and then bench Maria DBI.

91
00:06:38,020 --> 00:06:46,380
‫OK, yeah I'm inside of Maria Debe me increase the front of a little bit and now here I can again see

92
00:06:47,580 --> 00:06:54,630
‫describe and this will be Tabar I they Kim.

93
00:06:57,330 --> 00:07:01,150
‫And here, how do I go down here?

94
00:07:03,450 --> 00:07:06,540
‫I cannot go down, but wherever you find how.

95
00:07:40,950 --> 00:07:41,190
‫The.

96
00:07:48,100 --> 00:07:49,080
‫I got.

97
00:09:01,870 --> 00:09:08,890
‫And then the other thing is the default unit of measure, and we can see from here that we have stock

98
00:09:08,890 --> 00:09:14,420
‫you this is autisms that the default use of measure, unit of measure, put it here.

99
00:09:14,680 --> 00:09:18,580
‫And this one, I'm going to say that the unit of measure here is unit, OK?

100
00:09:19,360 --> 00:09:25,510
‫And then once that is done, then we need not to set this thing up to our database.

101
00:09:25,510 --> 00:09:27,670
‫So we need to save it now to a database.

102
00:09:28,030 --> 00:09:31,330
‫And how we do that, we see the variable put.

103
00:09:31,810 --> 00:09:34,570
‫In my case, it is at item dot.

104
00:09:36,180 --> 00:09:37,250
‫Don't insult.

105
00:09:39,960 --> 00:09:45,960
‫And this is going to be insulting to the database, but to confirm, just do Frappier DOD just to make

106
00:09:45,960 --> 00:09:50,460
‫sure that DBE don't commit could probably be commit.

107
00:09:50,470 --> 00:09:53,200
‫This ensures that this thing has been stuffed into the database.

108
00:09:53,220 --> 00:09:53,610
‫All right.

109
00:09:54,060 --> 00:09:55,250
‫So this is our function.

110
00:09:55,530 --> 00:09:56,720
‫Let's let's send it.

111
00:09:56,730 --> 00:10:03,540
‫I hope that you know what is going to happen here, so let's try and send it.

112
00:10:03,570 --> 00:10:05,510
‫I hope you have already guessed what's going to happen.

113
00:10:06,060 --> 00:10:10,080
‫We are we are going to call this function and then if they have that function.

114
00:10:15,010 --> 00:10:19,660
‫After we have we want to call this function and then if they have called this function, what we're

115
00:10:19,660 --> 00:10:26,350
‫going to do is we are going to go ahead and insert an item into a database so it can backfire and reload

116
00:10:26,380 --> 00:10:26,980
‫our table.

117
00:10:27,220 --> 00:10:28,810
‫And we have two items here.

118
00:10:29,200 --> 00:10:31,040
‫So what do you think is going to happen?

119
00:10:31,060 --> 00:10:35,430
‫So first of all, open will open another window and another tabone on.

120
00:10:35,440 --> 00:10:37,150
‫You are on you are on your posthuman.

121
00:10:37,510 --> 00:10:42,120
‫And then I can just copy this and put it here.

122
00:10:42,400 --> 00:10:48,190
‫But of course, remember, this last method is not going to be that, because if you run, this idea

123
00:10:48,190 --> 00:10:49,440
‫is going to get two items.

124
00:10:49,900 --> 00:10:53,560
‫What I want to do is to call the add item method.

125
00:10:53,560 --> 00:10:57,940
‫When I send that, of course, there's going to be a problem and it is telling you that you do not have

126
00:10:57,940 --> 00:10:58,940
‫permission to do that.

127
00:10:59,380 --> 00:11:03,910
‫Reason is because, like you guessed it, we do not adhere frappé.

128
00:11:03,940 --> 00:11:05,350
‫Dot, wait.

129
00:11:05,710 --> 00:11:10,650
‫OK, so we had not waitlisted listed our method here, so it's not going to work.

130
00:11:10,960 --> 00:11:11,920
‫So let me see again.

131
00:11:11,920 --> 00:11:13,180
‫Do you think this is going to work.

132
00:11:13,480 --> 00:11:15,040
‫Let's test it with our postman.

133
00:11:15,040 --> 00:11:15,670
‫Send it.

134
00:11:16,030 --> 00:11:20,860
‫And no, it is not going to result because this is not a public API.

135
00:11:20,860 --> 00:11:23,940
‫Remember here we we had to send this as a public API.

136
00:11:24,310 --> 00:11:25,720
‫This is not a public API.

137
00:11:25,930 --> 00:11:33,310
‫So what you need to do here is supply allergist's, which is true, which I do not think I'm going to

138
00:11:33,310 --> 00:11:33,580
‫do.

139
00:11:33,880 --> 00:11:37,530
‫I am going to set this thing as a protected DPA.

140
00:11:37,540 --> 00:11:38,800
‫So I'm going to do in this one.

141
00:11:39,250 --> 00:11:44,760
‫I am going to send my authorization token for this one.

142
00:11:45,040 --> 00:11:48,640
‫So go to the headers other key authorization

143
00:11:51,880 --> 00:11:56,500
‫authorization and paste your key here and then send in year.

144
00:11:56,500 --> 00:12:01,630
‫You have gotten some empty object and that is because we have not returned anything.

145
00:12:01,630 --> 00:12:04,230
‫If you check our code, we have not ordered to done anything.

146
00:12:04,540 --> 00:12:08,650
‫So when you come here and you refresh this, yes, you have API appetitive.

147
00:12:08,690 --> 00:12:12,160
‫So this one has been added from our API.

148
00:12:12,520 --> 00:12:15,760
‫If you need to return something, of course we need to return as our message.

149
00:12:15,940 --> 00:12:17,140
‫We can just return

150
00:12:19,690 --> 00:12:22,330
‫whatever you can just standard variable and that is it.

151
00:12:22,340 --> 00:12:30,820
‫So if you go back here now and maybe do y y y y and we do a second item and this is a service and that

152
00:12:30,820 --> 00:12:37,120
‫that's OK, we can go back here and send and I realized that this one has returned us.

153
00:12:37,120 --> 00:12:40,390
‫This is way, way, way, way and all the details of that item.

154
00:12:40,750 --> 00:12:44,800
‫And yes, when you come back to our ERP instance, we see that we have our second item.

155
00:12:44,800 --> 00:12:50,410
‫So this is an EPA that is working, but it cannot be consumed by a mobile app.

156
00:12:50,410 --> 00:12:52,930
‫That is because these things are hard coded.

157
00:12:52,930 --> 00:12:58,390
‫So in the next election, I am going to be showing you how to get these things from my mobile app all

158
00:12:58,390 --> 00:12:58,840
‫the way above.

159
00:12:58,840 --> 00:13:04,600
‫That is done with using using something like react like if you like, and you don't in any other front

160
00:13:04,600 --> 00:13:07,320
‫end technology that you are using.

161
00:13:07,330 --> 00:13:11,710
‫So thank you so much and see you in the next lecture.